package leecode

import "strings"

func findMaxForm(strs []string, m int, n int) int {
	dp := make([][]int, n+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, m+1)
	}
	//dp数组 最多有i个1 , j个0的最大子集的大小
	for _, str := range strs {
		zeroCount := strings.Count(str, "0")
		oneCount := strings.Count(str, "1")
		for i := n; i >= oneCount; i-- {
			for j := m; j >= zeroCount; j-- {
				dp[i][j] = max(dp[i][j], dp[i-oneCount][j-zeroCount]+1)
			}
		}
	}
	return dp[n][m]
}
